#include "team.h"
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

	players::players(){
		players::isFull = false; // setting it to false so it can add from the beggining
		numPlayers = 0; // setting it to 0 so we can start from scratch

	}
	void players::addPlayer(string playerName){
		players::playerName[numPlayers]=playerName; 
		// adds a player
		players::numPlayers++; // increases the players
		if(numPlayers == 5){
			cout <<endl;
			players::isFull = true; // if the team is full stop adding
		}
	}
	string players::getPlayers(){
		string playersnn;
		for(int i=0;i<players::numPlayers;i++){
			playersnn+=players::playerName[i];
			playersnn+="\n";
		}
		return playersnn;
	}
	void players::setName(string newName){
		players::teamName = newName; // assigning the team name with the input from the user
	}
	string players::getName(){
		return teamName; // return the team name
	}

	bool players::full(){

		return isFull;
	}

int _tmain(int argc, _TCHAR* argv[])
{
	string playerNam [10];
	players team1;
	players team2;
	players teams;
	string input;

	cout << "enter the first teams name : ";
	cin >> input;
	team1.setName(input); // assign the first teams name


	cout << "enter the second teams name : ";
	cin >> input;
	team2.setName(input); // assign the second teams name

	cout << "enter tha names of the players : \n";
	for(int i=0;i<10;i++){
	
	cin >> input;
	playerNam[i]=input;
	}

	int hi[10];
	srand(time(NULL));
	for(int i=0;i<10;i++){
		hi[i]=rand()%2;
		if(hi[i]==0 && !team1.full()){
			team1.addPlayer(playerNam[i]);
		}else if(hi[i]==0 && !team2.full()){
			team2.addPlayer(playerNam[i]);
		}else if(hi[i]==1 &&!team2.full()){
			team2.addPlayer(playerNam[i]);
		}else if(hi[i]==1&& !team1.full()){
			team1.addPlayer(playerNam[i]);
		}
	}
	cout << team1.getName(); 
	cout <<endl;
	cout<< team1.getPlayers();
	cout <<endl;
	cout << team2.getName();
	cout <<endl;
	cout<< team2.getPlayers();

	system("PAUSE");
	return 0;
}